home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
007
/
utils.mqc
/
utils.mac
Wrap
Text File
|
1985-09-10
|
12KB
|
449 lines
OPTS MACRO
.LALL
;; OPTIONS MODULE --- Ken Jones 1983
;; THIS MODULE IS USED TO CONTROL THE VARIOUS
;; ASSEMBLY TIME OPTIONS AND INITIALIZE
;; THE STANDARD EQUATES
ECNT = 0 ;ERROR COUNTER
VERSN = 1 ;CURRENT VERSION NUMBER
IBM = 1 ;SET FOR IBM ASSEMBLIES
.XALL
ENDM
ERRMSG MACRO TEXT
ECNT = ECNT+1
EMSG %ECNT,TEXT
ENDM
EMSG MACRO C,T
ERR&C DB 'E&C '
DB T,13,'$' ;TEXT OF MESSAGE
ENDM
GETLIB MACRO PARM
IF1
INCLUDE PARM
ENDIF
ENDM
SPACE MACRO LC
IFB <LC>
.LALL
;;
.XALL
ELSE
REPT LC
.LALL
;;
.XALL
ENDM
ENDIF
ENDM
EOJ MACRO RC
;; TERMINATE PROGRAM MACRO
SPACE
.LALL
; END OF PROGRAM
.XALL
SPACE
MOV AH,04CH ;SET EOJ FUNCTION DOS 2.0
MOV AL,RC ;SET RETURN CODE
INT 21H ;CALL DOS
ENDM
OPERWAIT MACRO BUFF
;; CLEAR BUFFER FOR STDIN AND WAIT FOR A KEY TO BE
;; PRESSED
SPACE
; WAIT FOR OPERATOR
SPACE
MOV DX,OFFSET BUFF ;LOCATE DATA BUFFER
MOV AL,0AH ;READ STDIN
MOV AH,0CH ;REQUEST BUFFER CLEAR
INT 21H ;CALL DOS
ENDM
OPEN MACRO FCB
;; OPEN FCB MACRO OLD STYLE
SPACE
; OPEN AN FCB
SPACE
MOV DX,OFFSET FCB ;LOCATE FILE FCB
MOV AH,0FH ;REQUEST OPEN
INT 21H ;CALL DOS
ENDM
CLOSE MACRO FCB
;; CLOSE AN FCB OLD STYLE
SPACE
; CLOSE AN FCB
SPACE
MOV DX,OFFSET FCB ;LOCATE FILE FCB
MOV AH,010H ;REQUEST CLOSE
INT 21H ;CALL DOS
ENDM
ERASE MACRO FCB
;; MACRO TO ERASE A DISK FILE
SPACE
; ERASE A FILE
SPACE
MOV DX,OFFSET FCB ;LOCATE FILE NAME
MOV AH,013H ;REQUEST ERASE FUNCTION
INT 21H ;CALL DOS
ENDM
GET MACRO FCB
;; SEQUENTIAL READ REQUEST
SPACE
; READ SEQUENTIAL
SPACE
MOV DX,OFFSET FCB ;LOCATE FCB FOR FILE
MOV AH,014H ;REQUEST READ
INT 21H ;CALL DOS
ENDM
PUT MACRO FCB
;; SEQUENTIAL WRITE
SPACE
; SEQUENTIAL WRITE TO FCB
SPACE
MOV DX,OFFSET FCB ;LOCATE FILE FCB
MOV AH,015H ;REQUEST WRITE FUNCTION
INT 21H ;CALL DOS
ENDM
CREATE MACRO FCB
;; OPEN A FILE FOR OUTPUT
SPACE
; OPEN OUTPUT FILE
SPACE
MOV DX,OFFSET FCB ;LOCATE FILE FCB
MOV AH,016H ;REQUEST CREATE FUNCTION
INT 21H
ENDM
READ MACRO FCB
;; RANDOM READ
SPACE
; RANDOM READ
SPACE
MOV DX,OFFSET FCB ;LOCATE FILE FCB
MOV AH,21H ;REQUEST READ
INT 21H ;CALL DOS
ENDM
WRITE MACRO FCB
;; RANDOM WRITE REQUEST
SPACE
; RANDOM WRITE OR UPDATE
SPACE
MOV DX,OFFSET FCB ;LOCATE FCB
MOV AH,22H ;REQUEST WRITE
INT 21H
ENDM
FILSIZE MACRO FCB
;; GET NUMBER OF RECORDS IN FILE FOR OPEN FCB
SPACE
; DETERMINE NUMBER OF RECORDS
SPACE
MOV DX,OFFSET FCB ;LOCATE FCB
MOV AH,23H ;REQUEST NO OF RECORDS
INT 21H ;CALL DOS
ENDM
STDOUT MACRO TEXT
;; WRITE TO STDOUT DEVICE FROM SPECIAL BUFFER
SPACE
.LALL
; PUT TO STDOUT DEVICE
.XALL
SPACE
MOV DX,OFFSET TEXT ;POINT AT DATA BUFFER
MOV AH,09H ;REQUEST OUTPUT
INT 21H ;CALL DOS
ENDM
STDIN MACRO BUFF
;; READ STANDARD INPUT DEVICE
SPACE
.LALL
; READ FROM STANDARD INPUT
; 1ST BYTE IN BUFFER IS SIZE OF BUFFER
; 2ND BYTE RETURNS NUMBER OF BYTES READ
; 3RD BYTE IS START OF INPUT DATA
; INPUT DATA IS FOLLOWED BY CARRIAGE RETURN X'13'
.XALL
SPACE
MOV DX,OFFSET BUFF ;LOCATE BUFFER
MOV AH,0AH ;REQUEST INPUT
INT 21H ;CALL DOS
ENDM
SETRRF MACRO FCB
;; SET UP RANDOM RECORD FIELD IN FCB
SPACE
; SET RANDOM RECORD FIELD
SPACE
MOV DX,OFFSET FCB ;LOCATE FCB
MOV AH,24H ;REQUEST SET FUNCTION
INT 21H ;CALL DOS
ENDM
SETDTA MACRO BUFF
MOV DX,OFFSET BUFF ;LOCATE BUFFER
MOV AH,1AH ;REQUEST SET DTA
INT 21H ;CALL DOS
ENDM
SETINT MACRO INO,NEW
;; ESTABLISH INTRAPROGRAM INTERRUPT VECTOR
;; CAUSES THE NUMBERED INTERRUPT TO VECTOR TO
;; THE ADDRESS GIVEN
SPACE
; SET INTERRUPT ADDR
SPACE
MOV DX,OFFSET NEW ;FIND ADDR OF INT CODE
MOV AL,INO ;FOR WHICH INTERRUPT
MOV AH,25H ;REQUEST SET FUNCTION
INT 21H ;TELL DOS
ENDM
DATE MACRO
SPACE
; GET DATE IN REGS
SPACE
MOV AH,2AH ;REQUEST DATE INFO
INT 21H ;CALL DOS
ENDM
TIME MACRO
SPACE
; GET TIME IN REGS
SPACE
MOV AH,2CH ;REQUEST TIME
INT 21H ;CALL DOS
ENDM
GETDTA MACRO
SPACE
; GET CURRENT DISK TRANSFER ADDR
SPACE
MOV AH,2FH ;REQUEST DTA ADDR
INT 21H ;CALL DOS
.LALL
;
; ES:BX NOW HAS DTA ADDR
;
.XALL
ENDM
GETINT MACRO INO
SPACE
; RESTORE INTERRUPT VECTOR TO NORMAL
SPACE
MOV AH,35H ;REQUEST RESTORE INT
MOV AL,INO ;GET NUMBER INT
INT 21H
.LALL
;
; ES:BX CONTAINS NORMAL ADDR
;
.XALL
ENDM
DSPACE MACRO DRIVE
SPACE
; FIND FREE SPACE ON A DRIVE
SPACE
MOV AH,36H ;REQUEST FREE SPACE
MOV DL,DRIVE ;DEFINE WHICH DRIVE
INT 21H ;CALL DOS
.LALL
;
; BX HAS NUMBER OF CLUSTER AVAILABLE
; DX HAS TOTAL CLUSTERS ON THE DRIVE
; CX HAS NUMBER OF BYTES PER SECTOR
; AX HAS NUMBER OF SECTORS PER CLUSTER
;
.XALL
ENDM
VERSION MACRO
SPACE
; GET DOS VERSION NUMBER
SPACE
MOV AH,30H ;REQUEST VERSION
INT 21H ;CALL DOS
.LALL
;
; AL HAS VERSION NUMBER
;
.XALL
ENDM
STAYRES MACRO ENDADDR
SPACE
; TERMINATE AND REMAIN RESIDENT
SPACE
MOV DX,OFFSET ENDADDR+1 ;FIND END OF PGM
INT 27H ;TELL DOS
ENDM
EOJOLD MACRO
;; EOJ FOR EARLY VERSIONS OF DOS
SPACE
; END OF JOB
SPACE
MOV AX,0 ;REQUEST TERMINATE
INT 21H ;BACK TO THE FARM
ENDM
PINIT MACRO PGNAME,PCNAME
NAME PGNAME
PAGE 55,132
SUBTTL PGNAME STARTING POINT
TITLE PGNAME
STACK SEGMENT PARA STACK
DW 200 DUP(?)
TOP_STACK LABEL FAR
STACK ENDS
;
;
PGNAME SEGMENT PARA 'MAIN'
ASSUME CS:PGNAME,DS:PGNAME,ES:PGNAME,SS:STACK
ORG 0100H
PCNAME PROC FAR
OPTS
DB '000000' ;RESERVE FOR BRANCH
PGMID DB 'PGNAME' ;PROGRAM NAME
ORG PGMID+8
DB %VERSN ;VERSION LEVEL
SAVEAREA
DB 'Your copy write here ..1984 ',10,13,'$'
ENDM
SAVEAREA MACRO
DSAVE DW ? ;SAVE DS REG
ESAVE DW ? ;SAVE ES REG
SSAVE DW ? ;SAVE SS REG
DISAVE DW ? ;SAVE DI REG
SISAVE DW ? ;SAVE SI REG
BPSAVE DW ? ;SAVE BP REG
SPSAVE DW ? ;SAVE SP REG
AXSAVE DW ? ;SAVE AX REG
BXSAVE DW ? ;SAVE BX REG
CXSAVE DW ? ;SAVE CX REG
DXSAVE DW ? ;SAVE DX REG
ENDM
SOJ MACRO STRT
STRT LABEL FAR
ORG 0100H
JMP STRT
ORG STRT
ENDM
SAVE MACRO
MOV DSAVE,DS ;save all regs
MOV ESAVE,ES
MOV SSAVE,SS
MOV DISAVE,DI
MOV SISAVE,SI
MOV BPSAVE,BP
MOV SPSAVE,SP
MOV AXSAVE,AX
MOV BXSAVE,BX
MOV CXSAVE,CX
MOV DXSAVE,DX
ENDM
RELOAD MACRO
MOV DS,DSAVE ;RESTORE ALL REGS
MOV ES,ESAVE
MOV SS,SSAVE
MOV DI,DISAVE
MOV SI,SISAVE
MOV BP,BPSAVE
MOV SP,SPSAVE
MOV AX,AXSAVE
MOV BX,BXSAVE
MOV CX,CXSAVE
MOV DX,DXSAVE
ENDM
ENDALL MACRO PGNAME,PCNAME
ENDPGM LABEL FAR
PCNAME ENDP
PGNAME ENDS
ENDM
FILL MACRO FLD,DATA,LNG
;; FILL A FIELD WITH THE BYTE SPECIFIED FOR THE
;; GIVEN LENGTH
MOV AL,DATA ;GET THE FILL CHARACTER
MOV DI,OFFSET FLD ;LOCATE DESTINATION
MOV CX,LNG ;SET LENGTH OF FILL
REP STOSB ;FILL IT
ENDM
SCANBYTE MACRO FLD,DATA,LNG,FND
LOCAL AGAIN
;; SCANS THE STRING 'FLD' FOR THE BYTE 'DATA'
;; FOR A LENGTH OF 'LNG'. IF A MATCH IS FOUND
;; BRANCH IS TAKEN TO 'FND'
MOV DI,OFFSET FLD ;LOCATE FIELD
MOV AL,DATA ;GET BYTE TO FIND
MOV CX,LNG ;SET LENGTH
AGAIN SCASB
JZ FND ;BRANCH IF FOUND
LOOP AGAIN ;KEEP GOING
ENDM
COPY MACRO FROM,TO,LNG
;; COPY FROM ADDR TO TO ADDR FOR LNG
MOV SI,OFFSET FROM ;GET SENDING FIELD
MOV DI,OFFSET TO ;GET DESTINATION
MOV CX,LNG ;SET LENGTH
REP MOVSB ;COPY THE DATA
ENDM
DSPLY MACRO MSG
MOV DX,OFFSET MSG
MOV AH,09H ;SET DISPLAY REQUEST
INT 21H ;CALL DOS
ENDM
REPLY MACRO BUF
PUSH DS
MOV DX,OFFSET BUF ;SET POINTER
MOV AH,0AH ;SET REQUEST
INT 21H ;CALL DOS
POP DS
ENDM
SCROLL MACRO
MOV AX,600H ;SCROLL WHOLE WINDOW
INT 10H ;CALL BIOS
ENDM
LOCATE MACRO
MOV AH,2 ;SELECT LOCATE
INT 10H
ENDM
KEYBOARD MACRO
MOV AH,10 ;SELECT READ
INT 21H ;CALL DOS
ENDM
BLANK MACRO
MOV CX,0 ;UPPER LEFT 0,0
MOV DX,2479H ;LOWER RIGHT
MOV BH,7 ;NORMAL ATTRIBUTE
SCROLL
ENDM